/**
 * Created by jipengcheng on 2017-12-18
 */
var tebWaitBuyerPay;//等待买家付款
var tebWaitSellerSend;//等待卖家发货
var tebTradePartiallySend;//交易部分发货
var tebTradeAllSend;//交易全部发货
var tebTradeFinished;//交易成功
var tebTradeCanceled;//交易取消
var searchCondition = { //高级检索
    "shopId": "",
    "shopType": "",
    "ecTradeCode": "",
    "ecCustCode": "",
    "ecTradeId": "",
    "childEcTradeId": "",
    "ecTradeStatus": ""
};
var quickSearch = "";       //快速查询
var btnAdvSearchflg = false; //高级查询是否点击标识
var mapOrderTable = {};
var orderId = "";
var ecTradeId = "";
var updateTime = "";

/**
 * 页面初期化
 */
$(document).ready(function () {

    //高级检索初期化的时候隐藏
    $("#advSearchPanel").hide();

    //默认  等待卖家发货
    getEbWaitSellerSend();

    //获取各种数字
    getCounts();
    //获取高级查询中店铺列表
    getShopList();

    //绑定事件
    /**
     * tab切换事件
     */
    $('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
        switch ($(this).attr("id")) {
            case "portlettabebTradeCanceledid":    //交易取消
                getebTradeCanceled();
                break;
            case "portlettabebTradeFinishedid":        //交易成功
                getebTradeFinished();
                break;
            case "portlettabebTradeAllSendid":        //交易全部发货
                getebTradeAllSend();
                break;
            case "portlettabebTradePartiallySendid":   //交易部分发货
                getebTradePartiallySend();
                break;
            case "portlettabebWaitSellerSendid":  //等待卖家发货
                getEbWaitSellerSend();
                break;
            case "portlettabebWaitBuyerPayid":       //等待买家付款
                getEbWaitBuyerPay();
                break;
            default:
                break;
        }
        getCounts();
    });

    // 高级搜索
    $("#advSearchPanel").hide();
    $("#btnAdvSearch").click(function () {
        btnAdvSearchflg = true;
        if ($("#advSearchPanel").is(":hidden")) {
        	$("#btnQuickSearch").hide();
            $("#advSearchPanel").show();
            $(this).children("i:eq(0)").removeClass("fa-angle-double-down");
            $(this).children("i:eq(0)").addClass("fa-angle-double-up");
        } else {
        	$("#advSearchPanel").hide();
            $("#btnQuickSearch").show();
            $(this).children("i:eq(0)").removeClass("fa-angle-double-up");
            $(this).children("i:eq(0)").addClass("fa-angle-double-down");
        }

    });
    $("#advSearchPanel").click(function () {
        btnAdvSearchflg = true;
    })

    /**
     * body点击的时候高级检索收回
     */
    /*$("body").click(function (e) {
        if (btnAdvSearchflg == true) {
            btnAdvSearchflg = false;
        } else {
            $("#advSearchPanel").hide();
            $("#btnAdvSearch").children("i:eq(0)").removeClass("fa-angle-double-up");
            $("#btnAdvSearch").children("i:eq(0)").addClass("fa-angle-double-down");
        }
    });*/

    // 高级搜索“提交”按钮点击
    $("#advSearchSubmit").click(function (e) {
        //记录高级查询的检索条件
        setHidValue("frmAdvSearch");
        searchCondition = { //高级检索
            "shopId": $('#hidshopId').val(),
            "shopType": $('#hidshopType').val(),
            "ecTradeCode": $('#hidecTradeCode').val(),
            "ecCustCode": $('#hidecCustCode').val(),
            "ecTradeId": $('#hidecTradeId').val(),
            "childEcTradeId": $('#hidchildEcTradeId').val(),
            "ecTradeStatus": $('#hidecTradeStatus').val(),
        };
        quickSearch = encodeURI($('#quickSearch').val());
        $("div .active").each(function () {
            switch ($(this).attr("id")) {
                case "portlettabebTradeCanceled":  //交易取消
                    tebTradeCanceled.draw();
                    break;
                case "portlettabebTradeFinished":      //交易成功
                    tebTradeFinished.draw();
                    break;
                case "portlettabebTradeAllSend":      //交易全部发货
                    tebTradeAllSend.draw();
                    break;
                case "portlettabebTradePartiallySend":     //交易部分发货
                    tebTradePartiallySend.draw();
                    break;
                case "portlettabebWaitSellerSend":        //等待卖家发货
                    tebWaitSellerSend.draw();
                    break;
                case "portlettabebWaitBuyerPay":     //等待买家付款
                    tebWaitBuyerPay.draw();
                    break;
                default:
                    break;
            }
        });
        getCounts();
//        $("#advSearchPanel").hide();
//        $("#btnAdvSearch").children("i:eq(0)").removeClass("fa-angle-double-up");
//        $("#btnAdvSearch").children("i:eq(0)").addClass("fa-angle-double-down");

    });

    /**
     * 快速搜索，点击时提交表格刷新内容
     */
    $("#btnQuickSearch").click(function () {
        quickSearch = encodeURI($('#quickSearch').val());
        searchCondition = { //高级检索
            "shopId": "",
            "shopType": "",
            "ecTradeCode": "",
            "ecCustCode": "",
            "ecTradeId": "",
            "childEcTradeId": "",
            "ecTradeStatus": ""
        };
        $("div .active").each(function () {
            switch ($(this).attr("id")) {
                case "portlettabcanceled":  //交易取消
                    tebTradeCanceled.draw();
                    break;
                case "portlettabebTradeFinished":      //交易成功
                    tebTradeFinished.draw();
                    break;
                case "portlettabebTradeAllSend":      //交易全部发货
                    tebTradeAllSend.draw();
                    break;
                case "portlettabwaiteSend":     //交易部分发货
                    tebTradePartiallySend.draw();
                    break;
                case "portlettabebWaitSellerSend":        //等待卖家发货
                    tebWaitSellerSend.draw();
                    break;
                case "portlettabebWaitBuyerPay":     //等待买家付款
                    tebWaitBuyerPay.draw();
                    break;
                default:
                    break;
            }
        });
        getCounts();
    });

    /**
     * 搜索框的回车事件
     */
    $('#quickSearch').keydown(function (e) {
        if (e.keyCode == 13) {
            $("#btnQuickSearch").click();
        }
    });
    
    //子表格显示隐藏
    $('.tablefirst tbody').on('click', 'td .fa', function () {
        //取得主键
        var ecTradeId = $(this).attr('ecTradeId');
        //取得行
        var tr = $(this).closest('tr');
        var row;
        var table;
        var tablename =  "";
        var tabIndex = "";
        $("div .active").each(function(){
            switch ($(this).attr("id")) {
            case "portlettabebTradeCanceled":  //交易取消
                table = tebTradeCanceled;
                row = tebTradeCanceled.row(tr);
                tablename = "tebTradeCanceled";
                tabIndex = "tebTradeCanceled";
                break;
            case "portlettabebTradeFinished":      //交易成功
                table = tebTradeFinished;
                row = tebTradeFinished.row(tr);
                tablename = "tebTradeFinished";
                tabIndex = "tebTradeFinished";
                break;
            case "portlettabebTradeAllSend":      //交易全部发货
                table = tebTradeAllSend;
                row = tebTradeAllSend.row(tr);
                tablename = "tebTradeAllSend";
                tabIndex = "tebTradeAllSend";
                break;
            case "portlettabebTradePartiallySend":     //交易部分发货
                table = tebTradePartiallySend;
                row = tebTradePartiallySend.row(tr);
                tablename = "tebTradePartiallySend";
                tabIndex = "tebTradePartiallySend";
                break;
            case "portlettabebWaitSellerSend":        //等待卖家发货
                table = tebWaitSellerSend;
                row = tebWaitSellerSend.row(tr);
                tablename = "tebWaitSellerSend";
                tabIndex = "tebWaitSellerSend";
                break;
            case "portlettabebWaitBuyerPay":     //等待买家付款
                table = tebWaitBuyerPay;
                row = tebWaitBuyerPay.row(tr);
                tablename = "tebWaitBuyerPay";
                tabIndex = "tebWaitBuyerPay";
                break;
            default:
                break;
            }
        });
        //加载过，而且是显示的状态
        if ( row.child.isShown() ) {
            // This row is already open - close it
            row.child.hide();
            tr.removeClass('shown');
            $(this).removeClass('fa-chevron-up');
            $(this).addClass('fa-chevron-down');
        }
        else {
            //关闭其他
            $('#'+tablename+' tbody tr').each(function(){
                if ($(this).attr("role")=="row"){
                    table.row($(this)).child.hide();
                }
            });
            $('.fa-chevron-up').addClass('fa-chevron-down');
            $('.fa-chevron-down').removeClass('fa-chevron-up');
            //生成datatable的HTML代码
            //判断相应的id的datatable是否存在
            if ($('#' + tablename + ecTradeId + tabIndex).length <= 0) {
                
                console.log(tablename + ecTradeId + tabIndex);
                
                var temp = '';
                temp += '<table id="' + tablename + ecTradeId + tabIndex +'"';
                temp += 'class="table table-hover table-striped table-bordered table-advanced tb-sticky-header"';
                temp += 'width="100%">';
                temp += '<thead>';
                temp += '<tr>';
                temp += '<th width="5%">平台商品编码</th>';
                temp += '<th width="5%">平台商品名称</th>';
                temp += '<th width="5%">平台规格编码</th>';
                temp += '<th width="5%">平台规格名称</th>';
                temp += '<th width="5%">平台状态</th>';
                temp += '<th width="5%">退款状态</th>';
                // temp += '<th width="5%">发货时间</th>';
                temp += '<th width="5%">物流公司</th>';
                temp += '<th width="5%">快递单号</th>';
                temp += '</tr>';
                temp += '</thead>';
                temp += '<tbody>';
                temp += '</tbody>';
                temp += '</table>';
                // Open this row
                row.child(temp).show();
                tr.addClass('shown');
                if (tablename == "tebWaitSellerSend"){
                    mapOrderTable[tablename + ecTradeId + tabIndex] = $('#' + tablename + ecTradeId + tabIndex).DataTable({
                        "bPaginate": false,
                        "processing": true,
                        "serverSide": true,
                        "lengthMenu": [[10, 25, 50, 100, 500, 1000], [10, 25, 50, 100, 500, 1000]],
                        "dom": '<"bottom"rtfli>',
                        "searching": false,
                        "pagingType": "full_numbers",
                        "deferRender": true,
                        "ajax": {
                            "url": "/ecTradeManager/getEcTradeOrderListNew.action",
                            "data": function (d) {
                                d.ecTradeId = encodeURI(ecTradeId);
                            }
                        },
                        "tableTools": {
                            "sRowSelect": "bootstrap"
                        },
                        "columns": [
                            {"data": "ecItemCode"},
                            {"data": "ecItemName"}, 
                            {"data": "ecSkuCode"},
                            {"data": "ecSkuName"},
                            {"data": "platformStatus"},
                            {"data": "refundStatus"},
                            // {"data": "shipTime"},
                            {"data": "lgstName"},
                            {"data": "lgstNo"}
                        ]
                        ,"order": [[0, "asc"],[2, "asc"]]
                    });
                } else {
                    mapOrderTable[tablename + ecTradeId + tabIndex] = $('#' + tablename + ecTradeId + tabIndex).DataTable({
                        "bPaginate": false,
                        "processing": true,
                        "serverSide": true,
                        "lengthMenu": [[10, 25, 50, 100, 500, 1000], [10, 25, 50, 100, 500, 1000]],
                        "dom": '<"bottom"rtfli>',
                        "searching": false,
                        "pagingType": "full_numbers",
                        "deferRender": true,
                        "ajax": {
                            "url": "/ecTradeManager/getEcTradeOrderListNew.action",
                            "data": function (d) {
                                d.ecTradeId = encodeURI(ecTradeId);
                            }
                        },
                        "tableTools": {
                            "sRowSelect": "bootstrap"
                        },
                        "columns": [
                            {"data": "ecItemCode"},
                            {"data": "ecItemName"}, 
                            {"data": "ecSkuCode"},
                            {"data": "ecSkuName"},
                            {"data": "platformStatus"},
                            {"data": "refundStatus"},
                            // {"data": "shipTime"},
                            {"data": "lgstName"},
                            {"data": "lgstNo"}
                        ]
                        ,"order": [[0, "asc"],[2, "asc"]]
                    });
                }
                
            } else {
                tr.addClass('shown');
            }
            $(this).addClass('fa-chevron-up');
            $(this).removeClass('fa-chevron-down');
        }
    });
});

/**
 * 获取店铺列表
 */
function getShopList() {
    //项目ID
    var prjId = encodeURI(encodeURI(window.top.window.$("#projectSwitch").val()));

    // 初始化店铺列表
    $.ajax({
        type: "GET",
        url: "/shop/getShopListByPrjId.action?prjId=" + prjId,
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        async: false,//同步
        success: function (data) {
            if (data.result == "success") {
                $("#shopId option").remove();
                $("#shopId").append("<option value=''>请选择</option>");
                $.each(data.data, function (n, value) {
                    $('#shopId').append("<option value='" + value.shopId + "' shopType = '" + value.shopType + "'>" + value.shopName + "</option>");
                });
            } else {
                window.top.window.showModalAlert(data.msg);
            }
        },
        error: function (XMLHttpRequest, textStatus) {
            if (XMLHttpRequest.status == 500) {
                var result = eval("(" + XMLHttpRequest.responseText + ")");
                alert(result.errorObject.errorText);
            }
        }
    });
};

/**
 * 等待买家付款 列表
 * @returns
 */
function getEbWaitBuyerPay() {
    //如果已经初期化过，不用重新定义，直接重画表格
    if (tebWaitBuyerPay != null && tebWaitBuyerPay != undefined && "" != tebWaitBuyerPay) {
        tebWaitBuyerPay.draw();
        return;
    }
    tebWaitBuyerPay = $('#tebWaitBuyerPay').DataTable({
        "processing": true,
        "serverSide": true,
        "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
        "dom": '<"bottom"rtflp>',
        "searching": false,
        "pagingType": "full_numbers",
        "deferRender": true,
        "ajax": {
            "url": "/ecTradeManager/getEbWaitBuyerPay.action",
            "data": function (d) {
                d.quickSearch = quickSearch;
                d.formJson = JSON.stringify(searchCondition);
            }
        },
        "tableTools": {
            "sRowSelect": "bootstrap"
        },
        "columns": [
            { "data": "ecOrderShow" }
            , { "data": "shopName" }
            , { "data": "ecTradeCode" }
            , { "data": "ecCustCode" }
            , { "data": "orderTime" }
        ],
        "columnDefs": [{
            "orderable": false,
            "targets": [0]
        }
        ]
        ,"order": [[1, "asc"], [4, "desc"]]
    });
}

/**
 * 等待卖家发货 列表
 * @returns
 */
function getEbWaitSellerSend() {
    //如果已经初期化过，不用重新定义，直接重画表格
    if (tebWaitSellerSend != null && tebWaitSellerSend != undefined && "" != tebWaitSellerSend) {
        tebWaitSellerSend.draw();
        return;
    }
    tebWaitSellerSend = $('#tebWaitSellerSend').DataTable({
        "processing": true,
        "serverSide": true,
        "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
        "dom": '<"bottom"rtflp>',
        "searching": false,
        "pagingType": "full_numbers",
        "deferRender": true,
        "ajax": {
            "url": "/ecTradeManager/getEbWaitSellerSend.action",
            "data": function (d) {
                d.quickSearch = quickSearch;
                d.formJson = JSON.stringify(searchCondition);
            }
        },
        "tableTools": {
            "sRowSelect": "bootstrap"
        },
        "columns": [
            { "data": "ecOrderShow" }
            , { "data": "shopName" }
            , { "data": "ecTradeCode" }
            , { "data": "ecCustCode" }
            , { "data": "orderTime" }
            , { "data": "paidTime" }
        ],
        "columnDefs": [{
            "orderable": false,
            "targets": [0]
        }
        ]
        ,"order": [[1, "asc"], [5, "desc"]]
    });
}

/**
 * 交易部分发货 列表
 * @returns
 */
function getebTradePartiallySend() {
    //如果已经初期化过，不用重新定义，直接重画表格
    if (tebTradePartiallySend != null && tebTradePartiallySend != undefined && "" != tebTradePartiallySend) {
        tebTradePartiallySend.draw();
        return;
    }
    tebTradePartiallySend = $('#tebTradePartiallySend').DataTable({
        "processing": true,
        "serverSide": true,
        "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
        "dom": '<"bottom"rtflp>',
        "searching": false,
        "pagingType": "full_numbers",
        "deferRender": true,
        "ajax": {
            "url": "/ecTradeManager/getEbTradePartiallySend.action",
            "data": function (d) {
                d.quickSearch = quickSearch;
                d.formJson = JSON.stringify(searchCondition);
            }
        },
        "tableTools": {
            "sRowSelect": "bootstrap"
        },
        "columns": [
            { "data": "ecOrderShow" }
            , { "data": "shopName" }
            , { "data": "ecTradeCode" }
            , { "data": "ecCustCode" }
            , { "data": "orderTime" }
            , { "data": "paidTime" }
        ],
        "columnDefs": [{
            "orderable": false,
            "targets": [0]
        }
        ]
        ,"order": [[1, "asc"], [5, "desc"]]
    });
}

/**
 * 交易全部发货 列表
 * @returns
 */
function getebTradeAllSend() {
    //如果已经初期化过，不用重新定义，直接重画表格
    if (tebTradeAllSend != null && tebTradeAllSend != undefined && "" != tebTradeAllSend) {
        tebTradeAllSend.draw();
        return;
    }
    tebTradeAllSend = $('#tebTradeAllSend').DataTable({
        "processing": true,
        "serverSide": true,
        "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
        "dom": '<"bottom"rtflp>',
        "searching": false,
        "pagingType": "full_numbers",
        "deferRender": true,
        "ajax": {
            "url": "/ecTradeManager/getEbTradeAllSend.action",
            "data": function (d) {
                d.quickSearch = quickSearch;//encodeURI($('#quickSearch').val());
                d.formJson = JSON.stringify(searchCondition);
            }
        },
        "tableTools": {
            "sRowSelect": "bootstrap"
        },
        "columns": [
            { "data": "ecOrderShow" }
            , { "data": "shopName" }
            , { "data": "ecTradeCode" }
            , { "data": "ecCustCode" }
            , { "data": "orderTime" }
            , { "data": "paidTime" }
            , { "data": "consignTime" }
        ],
        "columnDefs": [{
            "orderable": false,
            "targets": [0]
        }
        ]
        ,"order": [[1, "asc"], [6, "desc"]]
    });
}

/**
 * 交易成功 列表
 * @returns
 */
function getebTradeFinished() {
    //如果已经初期化过，不用重新定义，直接重画表格
    if (tebTradeFinished != null && tebTradeFinished != undefined && "" != tebTradeFinished) {
        tebTradeFinished.draw();
        return;
    }
    tebTradeFinished = $('#tebTradeFinished').DataTable({
        "processing": true,
        "serverSide": true,
        "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
        "dom": '<"bottom"rtflp>',
        "searching": false,
        "pagingType": "full_numbers",
        "deferRender": true,
        "ajax": {
            "url": "/ecTradeManager/getEbTradeFinished.action",
            "data": function (d) {
                d.quickSearch = quickSearch;//encodeURI($('#quickSearch').val());
                d.formJson = JSON.stringify(searchCondition);
            }
        },
        "tableTools": {
            "sRowSelect": "bootstrap"
        },
        "columns": [
            { "data": "ecOrderShow" }
            , { "data": "shopName" }
            , { "data": "ecTradeCode" }
            , { "data": "ecCustCode" }
            , { "data": "orderTime" }
            , { "data": "paidTime" }
            , { "data": "consignTime" }
            , { "data": "endTime" }
        ],
        "columnDefs": [{
            "orderable": false,
            "targets": [0]
        }
        ]
        ,"order": [[1, "asc"], [7, "desc"]]
    });
}

/**
 * 交易取消 列表
 * @returns
 */
function getebTradeCanceled() {
    //如果已经初期化过，不用重新定义，直接重画表格
    if (tebTradeCanceled != null && tebTradeCanceled != undefined && "" != tebTradeCanceled) {
        tebTradeCanceled.draw();
        return;
    }
    tebTradeCanceled = $('#tebTradeCanceled').DataTable({
        "processing": true,
        "serverSide": true,
        "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
        "dom": '<"bottom"rtflp>',
        "searching": false,
        "pagingType": "full_numbers",
        "deferRender": true,
        "ajax": {
            "url": "/ecTradeManager/getEbTradeCanceled.action",
            "data": function (d) {
                d.quickSearch = quickSearch;//encodeURI($('#quickSearch').val());
                d.formJson = JSON.stringify(searchCondition);
            }
        },
        "tableTools": {
            "sRowSelect": "bootstrap"
        },
        "columns": [
            { "data": "ecOrderShow" }
            , { "data": "shopName" }
            , { "data": "ecTradeCode" }
            , { "data": "ecCustCode" }
            , { "data": "orderTime" }
            , { "data": "paidTime" }
        ],
        "columnDefs": [{
            "orderable": false,
            "targets": [0]
        }
        ]
        ,"order": [[1, "asc"], [4, "desc"]]
    });
}

/**
 * 刷新
 * @returns
 */
function refresh() {
    $('#quickSearch').val("");
    quickSearch = "";
    $("#advSearchReset").click();
    searchCondition = {};
    if (!$("#advSearchPanel").is(":hidden")){
        $("#btnAdvSearch").click();   
    }  
    $("div .active").each(function () {
        switch ($(this).attr("id")) {
            case "portlettabebTradeCanceled":  //交易取消
                tebTradeCanceled.draw();
                break;
            case "portlettabebTradeFinished":      //交易成功
                tebTradeFinished.draw();
                break;
            case "portlettabebTradeAllSend":      //交易全部发货
                tebTradeAllSend.draw();
                break;
            case "portlettabebTradePartiallySend":     //交易部分发货
                tebTradePartiallySend.draw();
                break;
            case "portlettabebWaitSellerSend":        //等待卖家发货
                tebWaitSellerSend.draw();
                break;
            case "portlettabebWaitBuyerPay":     //等待买家付款
                tebWaitBuyerPay.draw();
                break;
            default:
                break;
        }
    });
    getCounts();
}

/**
 * 导出
 * @returns
 */
function exportEcTrade() {
    if (($('#shopId').val()==null || $('#shopId').val()=="" || $('#shopId').val()==undefined) &&
        ($('#shopType').val()==null || $('#shopType').val()=="" || $('#shopType').val()==undefined) &&
        ($('#ecTradeCode').val()==null || $('#ecTradeCode').val()=="" || $('#ecTradeCode').val()==undefined) &&
        ($('#ecCustCode').val()==null || $('#ecCustCode').val()=="" || $('#ecCustCode').val()==undefined)){
        window.top.window.showModalAlert("请输入查询条件后再导出");
        return false ;
    }

    var fileName = "";
    var sql = "";
    $("div .active").each(function () {
        switch ($(this).attr("id")) {
            case "portlettabebTradeCanceled":  //交易取消
                fileName = "交易取消";
                sql = 'exportSelectebTradeCanceled';
                break;
            case "portlettabebTradeFinished":      //交易成功
                fileName = "交易成功";
                sql = 'exportSelectebTradeFinished';
                break;
            case "portlettabebTradeAllSend":      //交易全部发货
                fileName = "交易全部发货";
                sql = 'exportSelectebTradeAllSend';
                break;
            case "portlettabebTradePartiallySend":     //交易部分发货
                fileName = "交易部分发货";
                sql = 'exportSelectebTradePartiallySend';
                break;
            case "portlettabebWaitSellerSend":        //等待卖家发货
                fileName = "等待卖家发货";
                sql = 'exportSelectebWaitSellerSend';
                break;
            case "portlettabebWaitBuyerPay":     //等待买家付款
                fileName = "等待买家付款";
                sql = 'exportSelectebWaitBuyerPay';
                break;
            default:
                break;
        }
    });

    //特殊情况（附加导出字段）
    var obj = new Object(); 
    obj.name = "项目名称";
    obj.value = "prjName";
    var obj1 = new Object();    
    obj1.name = "店铺名称";
    obj1.value = "shopName";
    var obj2 = new Object();    
    obj2.name = "平台交易号";
    obj2.value = "ecTradeCode";
    var obj3 = new Object();    
    obj3.name = "状态";
    obj3.value = "status";
    var obj4 = new Object();    
    obj4.name = "来源";
    obj4.value = "shopType";
    var obj5 = new Object();    
    obj5.name = "客户ID";
    obj5.value = "ecCustCode";
    var obj6 = new Object();    
    obj6.name = "拍单时间";
    obj6.value = "orderTime";
    var obj7 = new Object();    
    obj7.name = "付款时间";
    obj7.value = "paidTime";
    var obj8 = new Object();   
    obj8.name = "平台发货时间";
    obj8.value = "consignTime";
    var obj9 = new Object();    
    obj9.name = "完成时间";
    obj9.value = "endTime";
    var obj11 = new Object();   
    obj11.name = "平台商品编码";
    obj11.value = "ecItemCode";
    var obj12 = new Object();   
    obj12.name = "平台商品名称";
    obj12.value = "ecItemName";
    var obj13 = new Object();   
    obj13.name = "平台规格编码";
    obj13.value = "ecSkuCode";
    var obj14 = new Object();   
    obj14.name = "平台规格名称";
    obj14.value = "ecSkuName";
    var obj15 = new Object();   
    obj15.name = "平台状态";
    obj15.value = "ecOrderStatus";
    var obj16 = new Object();  
    obj16.name = "退款状态";
    obj16.value = "refundStatus";
    var obj19 = new Object();   
    obj19.name = "发货时间";
    obj19.value = "shipTime";
    var obj20 = new Object();   
    obj20.name = "物流公司";
    obj20.value = "lgstName";
    var obj21 = new Object();   
    obj21.name = "快递单号";
    obj21.value = "lgstNo";
    
    var ob = [obj,obj1,obj2,obj3,obj4,obj5,obj6,obj7,obj8,obj9,obj11,obj12,obj13,obj14,obj15,obj16,obj19,obj20,obj21];
    extraFieldJson = JSON.stringify(ob);

    exportList('', '/ecTradeManager/exportCheck.action', '/ecTradeManager/export.action', sql, fileName, 'frmAdvSearch', extraFieldJson)
}

/**
 * 取得tab上面的数字
 * @returns
 */
function getCounts() {
    $.ajax({
        type: "POST",
        url: "/ecTradeManager/getTabCountsNew.action?quickSearch=" + quickSearch, // + "&formJson=" + JSON.stringify(searchCondition) ,
        data: JSON.stringify(searchCondition),
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        async: true,//同步
        success: function (data) {
            
            //console.log(JSON.stringify(data));
            
            if (data.result == "success") {
                $("#portlettabebTradeCanceledid").html("交易取消(" + data.ebTradeCanceledCount + ")");
                $("#portlettabebTradeFinishedid").html("交易成功(" + data.ebTradeFinishedCount + ")");
                $("#portlettabebTradeAllSendid").html("交易全部发货(" + data.ebTradeAllSendCount + ")");
                $("#portlettabebTradePartiallySendid").html("交易部分发货(" + data.ebTradePartiallySendCount + ")");
                $("#portlettabebWaitSellerSendid").html("等待卖家发货(" + data.ebWaitSellerSendCount + ")");
                $("#portlettabebWaitBuyerPayid").html("等待买家付款(" + data.ebWaitBuyerPayCount + ")");
            } else {
                window.top.window.showModalAlert(data.msg);
            }
        },
        error: function (XMLHttpRequest, textStatus) {
            if (XMLHttpRequest.status == 500) {
                var result = eval("(" + XMLHttpRequest.responseText + ")");
                alert(result.errorObject.errorText);
            }
        }
    });
}
